Pushes value onto the back of target, a queue
queue_push(target, value) -> bool| Name | Type |
|---|---|
target | queue |
value | element |
bool
Pushes value onto the back of target, a queue<T> - first in, first out. Returns true if it fit, false if target was already full (nothing is pushed - target never crashes or corrupts, it just stops growing).
target is a real fixed-size double-ended queue that holds up to N items - N is target's own declared capacity (/// @capacity, default 8 if untagged). If the return value is ignored, target simply stops accepting new items until something is popped; check it only when the game needs to react to "no room left."
A queue<T>'s own capacity must always be a power of two (2, 4, 8, 16, 32, ...) - its underlying storage (a double-ended queue) requires it. /// @capacity 10 is refused at check time, naming the nearest legal size to use instead (16); the untagged default (8) already satisfies this, so an untagged queue<T> is never affected.
queue<T> has no [i] indexing - unlike array<T>/list<T>/grid<T>, the front is the only item you can ever reach directly. Declare the variable list<T> instead if you need to look inside it by index or search it.
/// @type {queue<int>}
/// @capacity 4
var turn_order = [];
queue_push(turn_order, 1);
var added = queue_push(turn_order, 2); // true - there was room



target is a real fixed-size double-ended queue of T items, up to N - N is target's own declared capacity (`/// @capacity`, default 8 if untagged, and always a POWER OF TWO - any other tagged value is refused at check time, see this file's own Queues header). Checks target.full() before ever calling push_back, the identical safety check stack_push/list_add already make. O(1).